<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/30
 * Time: 11:31
 */
namespace app\api\validate;
use think\Validate;

class Login extends Validate
{
    protected $rule = [
        'password' => 'require|length:5,21|regex:/^(?=.*[0-9a-zA-Z]).{6,20}$/',
        'phone' => ['require','regex' => '/^1[3|4|5|7|8][0-9]\d{4,8}$/i'],
        'code' => 'require'
    ];
    protected $message = [
        'phone.require' => 400001,
        'phone.regex' => 400003,
        'phone.unique' => 400004,
        'password.require' => 400002,
        'password.length' => 400005,
        'password.regex' => 400006,
        'code.require' => 400007,
    ];
    protected $scene = [
        'password_login' =>  ['password'],
        'register' => ['phone' => 'require', 'password', 'code'],
        'register_add' => ['phone' => ['require','regex' => '/^1[3|4|5|7|8][0-9]\d{4,8}$/i', 'unique:member'],'password'],
        'retrieve_password' => ['phone' => ['require','regex' => '/^1[3|4|5|7|8][0-9]\d{4,8}$/i'],'password'],
    ];
}